﻿using com.fukefu.sql;

namespace com.fukefu.tools
{
    public class Site
    {
        string wid = null;
        string title = null;
        string domain = null;
        string[] typeId = null;
        string className = null;
        int loginAuto = 0;
        int postAuto = 0;
        int btMaxLen = 0;
        int sleepTime = 0;
        int _LoginVcode = 0;
        int _PostVcode = 0;

        public Site(string wid, string title, string domain, string typeId, int btMaxLen, int sleepTime, int loginvcode, int postvcode, string className)
        {
            this.wid = wid;
            this.title = title;
            this.domain = domain;
            this.typeId = typeId.Split('|');
            this.btMaxLen = btMaxLen;
            this.sleepTime = sleepTime * 1000;
            this._LoginVcode = loginvcode;
            this._PostVcode = postvcode;
            this.className = className;
        }
        //网站id
        public string Wid
        {
            get { return wid; }
        }
        //网站名称
        public string Title
        {
            get { return title; }
        }
        //域名
        public string Domain
        {
            get { return domain; }
        }
        //栏目分类
        public string[] TypeId
        {
            get { return typeId; }
        }
        //标题最大长度
        public int BtMaxLen
        {
            get { return btMaxLen; }
        }
        //发布间隔设置
        public int SleepTime
        {
            get { return sleepTime; }
        }
        //类名字
        public string ClassName
        {
            get { return className; }
            set { className = value; }
        }
        //登陆时候是否需要验证码
        public bool LoginVcode
        {
            get
            {
                if (_LoginVcode == 1)
                { return true; }
                else
                { return false; }
            }
        }
        public bool LoginAuto
        {
            get
            {
                if (loginAuto == 1)
                {
                    return true;
                }
                return false;
            }
        }
        public bool PostAuto
        {
            get
            {
                if (postAuto == 1)
                {
                    return true;
                }
                return false;
            }
        }
        //发布的时候是否需要验证码
        public bool PostVcode
        {
            get
            {
                if (_PostVcode == 1)
                { return true; }
                else
                { return false; }
            }
        }
        //今日发布数量
        public int TodayPublicNum
        {
            get
            {
                int num = 0;
                SqlServerOperate sql = new SqlServerOperate();
                num = sql.GetQueryNum("select count(1) from 已发布 as a,_site_账户 as b where datediff(d,a.dt,getdate())=0 and b.wid='" + wid + "' and a.uid=b.uid");
                sql.Close();
                return num;
            }
        }
    }
}
